home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
js
/
remoteDesktop-src.js
< prev
next >
Wrap
Text File
|
2010-05-19
|
25KB
|
784 lines
var XX,YY; // Mouse coordinates
var startX,startY; // Mouse drag start coordinates
var winState='normal'; // Current window state ('minMax', 'minNormal') (used to stop refreshing when viewport hidden)
var mixedEvents=''; // Mouse / keyboard event string sent to server. Events are separated by a slash
var keyEvents=''; // Keyboard events
var keyPressedCalled=0;
var rdTimeout=false; // Tiemout used to sendEvents()
var focusInterval;// window interval used to keep focus on keys2 input, toggled with resumeFocus(0/1);
var inputBoxDragInProgress=0;
var sendEventsInProgress=0; // 1 if a sendData request is in progress
var sendEventsImmediately=0;
var maskDragInProgress=0;
var inputBoxFocused=0;
var clipboardBoxFocused=0;
var keyBuffer="";
var lastKeyPressedKC=0;
var lastKeyDownDate=0; // Time(ms) of last processed keydown, used to prevent double keystrokes under FF
var shiftDown=false; var shiftUsed=0;
var ctrlDown=false; var ctrlUsed=0;
var altDown=false; var altUsed=0;
var showMouseIcon=1;
var pws="";
var maskFaded=1;
var inputsDisabled=0;
var mouseIn=1; // 1 if mouse over mask/window
var dbsl=0,dbst=0; // D.body.scrollTop/Left
/******************************************************************************
* Misc functions
*****************************************************************************/
function stopLoading(){
windowStop();
var n,i=0;
while(n=dgi("sq"+i)) {imgBuff[i].src=n.src="/gfx/v.gif";i++}
}
/**
* Called before showing resouce configuration form
*/
function beforeConfigureResource(){}
/**
* Set mouse in or out of window
*/
var mouseAreaLastXY;
function winMouseIn(){
mouseIn=1;
resumeFocus(1);
//dgi('debugDiv').innerHTML='in'
}
function winMouseOut(){
mouseIn=0;
resumeFocus(0);
}
/**
* Start / Stop focussing on keys2 input to get keyboard events
*/
function resumeFocus(f){
if(altClick) return; // Never use keys2 focus with alternate click menu
// Resume focussing
if(f && !focusInterval && !focusIntervalSuspended && dgi('keys2')){
focusInterval=setInterval("dgi('keys2').focus()",100);
}
// Stop focussing
if(!f && focusInterval){
clearInterval(focusInterval);
focusInterval=0;
}
}
// Set inputBox and controlBox dimensions so content fit (WA)
function inputBoxesResetSize(){
if(dd.elements["controlBox"]) dd.elements["controlBox"].resizeTo(actualOffsetRight(dgi("controlBoxLE"))-actualOffsetLeft(dgi("controlBox"))+10,false);
if(dd.elements["inputBox"]) dd.elements["inputBox"].resizeTo(actualOffsetRight(dgi("inputBoxLE"))-actualOffsetLeft(dgi("inputBox"))+10,false);
}
function toggleDebug(){
debug=!debug;
if(debug) dgi('debugDiv').style.display="block"; else dgi('debugDiv').style.display="none";
}
function trace(txt){if(dgi('debugDiv')) dgi('debugDiv').innerHTML=txt+'<br>'+dgi('debugDiv').innerHTML;}
function unprotect(str){
return str.replace(/&/gi,"&").replace(/</gi,"<").replace(/!weezobr!/gi,String.fromCharCode(10));
}
function protect(str){
return str.replace(/[\/]/gi,"*weezoslash*").replace(/[&]/gi,"*weezoamp*");
}
/**
* (re) set main event timeout.
* @param: newInt: new timeout, in ms
* @param preserveExistingTimeout: true to use current timeout if already set
*/
function setEvtInterval(newInt,preserveExistingTimeout){
if(rdTimeout!==false) {
if(preserveExistingTimeout) return;
clearTimeout(rdTimeout);
}
rdTimeout=false;
if(newInt) rdTimeout=setTimeout('sendEvents()',newInt);
else sendEventsImmediately=0;
}
// Safety timer called by sendEvents on request cancel because another request is already in progress
function eventTimeoutSafety(){
if(!eventTimeoutSafetySet) return; // If a new request has been fired since eventTimeoutSafety set, cancel
sendEventsInProgress=0;
sendEvents();
}
// Window minimized or state changed
function winStateChanged(prev,current){
winState=current;
if(current=='minMax' || current=='minNormal') {
winMouseOut();
setEvtInterval(0);
}
else if(prev=='minMax' || prev=='minNormal') {
sendEvents();
}
}
function setMouseIcons(iHTML){
if(!showMouseIcon) return;
dgi("mouseIcons").innerHTML+=iHTML;
// Set mouseIcons layer below mask layer
if(dd.elements["mask"]) dd.elements["mask"].maximizeZ();
if(dd.elements["inputBox"]) dd.elements["inputBox"].maximizeZ();
if(dd.elements["controlBox"]) dd.elements["controlBox"].maximizeZ();
if(dd.elements["clipboardBox"]) dd.elements["clipboardBox"].maximizeZ();
}
function clearMouseIcons(){dgi("mouseIcons").innerHTML='';}
function blink(eltName,times,action){
if(!action) action="hide";
if(winMe.addControls) elts=parent.D.getElementsByName(eltName);
else elts=D.getElementsByName(eltName);
for(var i=0;i<elts.length;i++){
if(action=="hide") elts[i].style.visibility="hidden"; else elts[i].style.visibility="visible";
}
if(action=="hide") setTimeout('blink("' + eltName + '", ' + times + ', "show")',100);
else {
if((times--)>0) setTimeout('blink("' + eltName + '", ' + (times) + ', "hide")',100);
}
}
// Update "keys in progress" box with current key events and modifiers
function modKeyIcon(mk){return '<img src="/gfx/v.gif" class="modKey '+mk+'">'}
function gfxKE(ke){
ke=ke.replace(/[+]/g,'*plus*').replace(/%/g,'*alt*').replace(/\^/g,'*ctrl*')
ke=ke.replace(/{\*plus\*}/g,'+').replace(/{\*alt\*}/g,'%').replace(/{\*ctrl\*}/g,'^')
ke=ke.replace(/\*plus\*/g,modKeyIcon("shift"))
ke=ke.replace(/{SHIFT}/g,modKeyIcon("shift")+" ")
ke=ke.replace(/\*alt\*/g,modKeyIcon("alt"))
ke=ke.replace(/{ALT}/g,modKeyIcon("alt")+" ")
ke=ke.replace(/\*ctrl\*/g,modKeyIcon("ctrl"))
ke=ke.replace(/{CTRL}/g,modKeyIcon("ctrl")+" ")
ke=ke.replace(/{ENTER}/g,modKeyIcon("ENTER"))
ke=ke.replace(/{BACKSPACE}/g,modKeyIcon("BACKSPACE"))
ke=ke.replace(/{ESC}/g,modKeyIcon("ESC"))
ke=ke.replace(/{UP}/g,modKeyIcon("UP"))
ke=ke.replace(/{DOWN}/g,modKeyIcon("DOWN"))
ke=ke.replace(/{LEFT}/g,modKeyIcon("LEFT"))
ke=ke.replace(/{RIGHT}/g,modKeyIcon("RIGHT"))
ke=ke.replace(/{DELETE}/g,modKeyIcon("DELETE"))
ke=ke.replace(/{INSERT}/g,modKeyIcon("INSERT"))
ke=ke.replace(/{HOME}/g,modKeyIcon("HOME"))
ke=ke.replace(/{END}/g,modKeyIcon("END"))
ke=ke.replace(/{PGUP}/g,modKeyIcon("PGUP"))
ke=ke.replace(/{PGDN}/g,modKeyIcon("PGDN"))
ke=ke.replace(/{NUMLOCK}/g,modKeyIcon("NUMLOCK"))
ke=ke.replace(/{CAPSLOCK}/g,modKeyIcon("CAPSLOCK"))
ke=ke.replace(/{TAB}/g,modKeyIcon("TABUL"))
return ke;
}
function updateWS(){
var ws="";
if(!inputBoxFocused){
if(!keyEvents.length){
if(shiftDown) ws+=modKeyIcon('shift');
if(ctrlDown) ws+=modKeyIcon('ctrl');
if(altDown) ws+=modKeyIcon('alt');
}
ws+=" "+gfxKE(keyEvents);
}
if(ws==pws) return;
if(keyEvents.length>0 || shiftDown || ctrlDown || altDown){
dgi("nStatus").style.display="block";
dgi("nStatus").innerHTML=ws;
}
else dgi("nStatus").style.display="none";
pws=ws;
}
function toggleInputBox(){
if(displayInputBox=!displayInputBox) {
dd.elements["inputBox"].moveTo(dd.elements["controlBox"].x, dd.elements["controlBox"].y);
dd.elements["controlBox"].moveTo(-1000,-50);
sendData("displayInputBox=true&noSt=true",PHP_SELF,false);
}
else{
dd.elements["controlBox"].moveTo(dd.elements["inputBox"].x, dd.elements["inputBox"].y);
dd.elements["inputBox"].moveTo(-1000,-50);
sendData("displayInputBox=false&noSt=true",PHP_SELF,false);
}
focusKeyInput();
}
// Change zoom to 1:1 ratio (type='restore') or to adjust/fit screen (type='adapt')
function changeZoom(type){
stopLoading();
fas('',type,winMe.getInnerWidth()-3,winMe.getInnerHeight()-3);
}
// Select screen
function setScreen(nb){
stopLoading();
fas(nb,'setScreen',winMe.getInnerWidth()-3,winMe.getInnerHeight()-3,'sync');
}
function fadeMask(){
if(dd.ie) dgi("mask").style.filter="Alpha(opacity=50, style=0)";
else dgi("mask").style.background="url('mbg.png')";
maskFaded=true;
resumeFocus(0);
focusIntervalSuspended=1;
}
function showMask(){
if(inputBoxDragInProgress) return;
if(dd.ie) dgi("mask").style.filter="Alpha(opacity=1, style=0)";
else dgi("mask").style.background="transparent";
maskFaded=false;
focusIntervalSuspended=0;
resumeFocus(1);
inputBoxFocused=false;
}
/******************************************************************************
* Redraw squares
*****************************************************************************/
function updateSquares(str){
if(!str){
for(var i=0; i<D.getElementsByName('sqi').length; i++) dgi("sq"+i).src=rdPath + '/' +Math.floor(1000000*Math.random()) + '/' + i + ".jpg";
setEvtInterval(refreshAfterNoEvent,1);
return;
}
var exp=str.split(";");
sendEventsInProgress=0;
if(sendEventsImmediately) sendEvents();
sendEventsImmediately=0;
for(var i=0; i<exp.length; i++){
squareSeq[i]=parseInt(squareSeq[i]);
if(exp[i]>squareSeq[i]) {
imgBuff[i].src=rdPath + '/' + exp[i] + '/' + i + ".jpg";
if(debug) {
dgi("sq"+i).className="debugSquare";
dgi("dbgSq"+i).style.color="red";
dgi("dbgSq"+i).innerHTML=exp[i];
}
squareSeq[i]=exp[i];
}
else if(debug) {
dgi("sq"+i).className="debugSquareNR";
dgi("dbgSq"+i).style.color="blue";
}
}
}
/**
* @desc Function called when buffer image loaded => replace shown image src with this
*/
function imgBuffLoaded(){dgi("sq"+this.alt).src=this.src}
// Set mouse position and modifier keys states
function setState(e){
if (e && e.pageX!=undefined) {
// Opera shift+arrow mousemove workaround
if(phpBrowser=='opera' && !e.pageX && !e.pageY){
// Prev position too far from corner...
if(XX+YY>50){
keyProcessMods(e);
return;
}
}
XX=e.pageX;
YY=e.pageY;
}
else {
XX=event.x+D.body.scrollLeft;
YY=event.y+D.body.scrollTop;
}
YY-=actualOffsetTop(dgi('squares'));
keyProcessMods(e);
}
/******************************************************************************
* Mouse & keyboard Events
*****************************************************************************/
// Add event to events buffer
function addEvent(evt){
if(!mouseIn && evt.substr(0,3)=="mmv") return;
if(evt.substr(0,3)=="mmv" && evt.indexOf('undefined')!=-1) return;
if(mixedEvents.length>0) mixedEvents+="/";
mixedEvents+=evt;
}
// Send all events to server
function sendEvents(){
// If window is minimized, don't send
if(winState=='minMax' || winState=='minNormal') return;
clearMouseIcons();
// If an event has already been sent but response has not been received
if(sendEventsInProgress){
sendEventsImmediately=1; // Indicate updateSquare to send new events as soon as it receive response from server
eventTimeoutSafetySet=1;
setTimeout('eventTimeoutSafety()',3*refreshAfterNoEvent); // Set a safety timer in case of no server response (WA)
return;
}
eventTimeoutSafetySet=0;
sendEventsInProgress=1;
seq++;
if(mixedEvents==""){
if(!altClick) addEvent("mmv;"+XX+";"+YY+";");
//if(debug) dbgw(seq + "&evts="+mixedEvents);
sendData("noSt=true&seq=" + seq + "&sendMixedEvents="+mixedEvents,PHP_SELF,false);
mixedEvents=""; keyEvents=""; updateWS();//clearMouseIcons();
setEvtInterval(refreshAfterNoEvent);
}
else {
//if(debug && mixedEvents) trace(mixedEvents);
if(!altClick) addEvent("mmv;"+XX+";"+YY+";");
command="seq="+seq+"&noSt=true&sendMixedEvents="+encodeURIComponent(mixedEvents);
//if(debug) dbgw(seq+'&evts='+mixedEvents);
sendData(command,PHP_SELF,true);
mixedEvents=""; keyEvents=""; updateWS();//clearMouseIcons();
setEvtInterval(refreshAfterEvent);
}
}
/******************************************************************************
* Mouse Events
*****************************************************************************/
// IE
function watchScrollBars(){
if(D.body.scrollLeft==dbsl && D.body.scrollTop==dbst) return;
dbsl=D.body.scrollLeft;
dbst=D.body.scrollTop;
dgi("keys2div").style.left=(dbsl+D.body.offsetWidth/2)+"px";
dgi("keys2div").style.top=(dbst+D.body.offsetHeight/2)+"px";
}
/**
* Update mouse coordinates, and position elements according to mouse position
*/
function updateMousePos(e){
setState(e);
updateWS();
dgi("nStatus").style.left=(XX+15)+"px";
dgi("nStatus").style.top=(YY)+"px";
dgi("keys2div").style.left=(D.body.scrollLeft+winMe.getInnerWidth()/2)+"px";
dgi("keys2div").style.top=(D.body.scrollTop+winMe.getInnerHeight()/2)+"px";
XX=Math.round(XX*1.0/zoom);
YY=Math.round(YY*1.0/zoom);
if(maskDragInProgress && dd.obj && dd.obj.name=="mask") {
var sel=dgi("select").style;
if(startX>XX) {sel.left=XX*zoom; sel.width=(startX-XX)*zoom;} else {sel.left=startX*zoom; sel.width=(XX-startX)*zoom;}
if(startY>YY) {sel.top=YY*zoom; sel.height=(startY-YY)*zoom;} else {sel.top=startY*zoom; sel.height=(YY-startY)*zoom;}
sel.display="block";
}
}
/**
* Add a mouse event (rc, lc, ld, lu) to buffer
*/
function updateMouseEvents(action){
if(maskFaded) return;
setEvtInterval(0); // Clear timeout so nothing happends during this process
if(action=='rd'||action=='ru') setMouseIcons('<div style="position:absolute;top:'+(YY*zoom-16)+'px;left:'+(XX*zoom-16)+'px;">'+dgi("mouseR").innerHTML+'</div>');
else{
if(action!='move') setMouseIcons('<div style="position:absolute;top:'+(YY*zoom-16)+'px;left:'+(XX*zoom-16)+'px;">'+dgi("mouseL").innerHTML+'</div>');
}
var mouseEvent=action+";"+XX+";"+YY+";";
if(shiftDown) {mouseEvent+="+"; shiftUsed=true;}
if(altDown) {mouseEvent+="%"; altUsed=true;}
if(ctrlDown) {mouseEvent+="^"; ctrlUsed=true;}
addEvent("m"+mouseEvent);
if(action!='ld' && action!='rd') setEvtInterval(eventMaxDurationMouse);
}
// Mouse down on mask (start dragging)
function preDrag(){
if(altClick) return;
if(dd.obj.name=="mask"){
startX=XX; startY=YY;
maskDragInProgress=true;
var sel=dgi("select").style; sel.left=XX*zoom; sel.top=YY*zoom; sel.height=0; sel.width=0; sel.display="block";
if(dd.e.button>1) updateMouseEvents("rd"); else updateMouseEvents("ld");
}
if(dd.obj.name=="inputBox" || dd.obj.name=="controlBox" || dd.obj.name=="clipboardBox") inputBoxDragInProgress=true;
focusKeyInput();
}
// Mouse up on mask (done dragging)
function preDrop(){
maskDragInProgress=false;
dgi("select").style.display="none";
if(dd.obj.name=="inputBox" || dd.obj.name=="controlBox" || dd.obj.name=="clipboardBox") inputBoxDragInProgress=false;
else {
if(dd.e.button>1) updateMouseEvents("ru"); else updateMouseEvents("lu");
}
}
// Right-click action
//function onrightclick(e){updateMouseEvents("rc")}
/******************************************************************************
* Keyboard events
*****************************************************************************/
function keyAddSeq(sq){
//addEvent("mmv;"+XX+";"+YY+";");
addEvent("k"+protect(sq));
keyEvents+=sq.replace(/ /," ");
updateWS();
setEvtInterval(eventMaxDurationKb);
}
function keyStrikeAdd(k){
var key="";
if(ctrlDown) key+="^";
if(altDown) key+="%";
if(k=="+") k="{+}";
if(k=="%") k="{%}";
if(k=="^") k="{^}";
if(k=="~") k="{~}";
if(k=="{") k="{{}";
if(k=="}") k="{}}";
if(k=="[") k="{[}";
if(k=="]") k="{]}";
if(key=='^%' && k=='+{DELETE}') k='{DELETE}'; // Ctrl-Alt-Suppr
shiftUsed=false;
altUsed=false;
ctrlUsed=false;
keyAddSeq(key+k);
}
var lastModKeys;
function keyProcessMods(e){
kc=27;
if(e){ // Gecko
kc=e.which;
if(e.shiftKey) keySetMod("shift",true); else keySetMod("shift",false);
if(e.altKey) keySetMod("alt",true); else keySetMod("alt",false);
if(e.ctrlKey) keySetMod("ctrl",true); else keySetMod("ctrl",false);;
}
else if(W.event){ // IE & Opera
kc=W.event.keyCode;
if(W.event.shiftKey) keySetMod("shift",true); else keySetMod("shift",false);
if(W.event.altKey) keySetMod("alt",true); else keySetMod("alt",false);
if(W.event.ctrlKey) keySetMod("ctrl",true); else keySetMod("ctrl",false);
}
if(lastModKeys!=" "+altDown+ctrlDown+shiftDown) updateWS();
lastModKeys=" "+altDown+ctrlDown+shiftDown;
return kc;
}
function keySetMod(mod,val){
if(mod=='alt') {
if(!altDown && val) altUsed=true;
altDown=val;
}
if(mod=='ctrl') {
if(!ctrlDown && val) ctrlUsed=true;
ctrlDown=val;
}
if(mod=='shift') {
if(!shiftDown && val) shiftUsed=true;
shiftDown=val;
}
}
function keyProcessInput(){
if(dgi('keys2').value.length>0 && dgi('keys2').value.length<3) { // <3 to correct paste problem (ctr-v in input)
keyStrikeAdd(dgi('keys2').value.replace(/\n/,'{ENTER}'));
dgi('keys2').value="";
return true;
}
return false;
}
function keyDown(e){
if(maskFaded) return;
if((new Date()).getTime()-lastKeyDownDate<5) return;
lastKeyDownDate=(new Date()).getTime();
kc=keyProcessMods(e);
if(inputsDisabled) return;
keyPressedCalled=1;
setTimeout('keyPressed('+kc+')',1);
if((ctrlDown && !altDown) || sk[kc]) return false;
}
function keyPress(e){
if(maskFaded) return;
kc=keyProcessMods(e);
if(inputsDisabled) return;
if(keyPressedCalled) return;
if(keyProcessInput()) keyCancelkeyPressed=1;
}
function keyUp(e){
if(maskFaded) return;
kc=keyProcessMods(e);
if(inputsDisabled) return;
if(!keyPressedCalled) keyProcessInput();
mods="";
if(altDown) mods+="%";
if(ctrlDown) mods+="^";
if(shiftDown) mods+="+";
if(kc==18 && altUsed) {altUsed=false;ctrlUsed=false;shiftUsed=false;keyAddSeq(mods+'{ALT}');}
if(kc==17 && ctrlUsed) {altUsed=false;ctrlUsed=false;shiftUsed=false;keyAddSeq(mods+'{CTRL}');}
if(kc==16 && shiftUsed) {altUsed=false;ctrlUsed=false;shiftUsed=false;keyAddSeq(mods+'{SHIFT}');}
}
function keyPressed(kc){
keyPressedCalled=0;
if(kc==86 && ctrlDown) dgi("keys2").value='';
if(!keyProcessInput()){
if(sk[kc]) {
keyStrikeAdd(((shiftDown)?'+'+sk[kc]:sk[kc]));
}
else{
if(kc<32) return;
if(String.fromCharCode(kc)!==false) {
if(ctrlDown || altDown) keyStrikeAdd(String.fromCharCode(kc).toLowerCase());
}
}
}
}
// Send keys from keys input box
function sendKeys(){
var cont;
if(winMe.addControls) cont=parent; else cont=window;
if(cont.dgi("keys").value.length==0) return;
addEvent("mmv;"+XX+";"+YY+";");
addEvent("k"+cont.dgi("keys").value);
sendEvents();
cont.dgi("keys").value="";
}
// Clear keys input box
function clearKeys(){
var cont=(winMe.addControls)?parent:W;
cont.dgi("keys").value="";
}
function insertKey(){
var cont;
if(winMe.addControls) cont=parent; else cont=window;
if(cont.dgi("specialKeySelect").value=='Cancel') return;
cont.dgi("keys").value+=cont.dgi("specialKeySelect").value;
cont.dgi("keys").focus();
cont.dgi("specialKeySelect").value='Cancel';
}
function focusKeyInput(){
if(maskFaded || displayInputBox || clipboardBoxFocused) {
resumeFocus(0);
return;
}
updateWS();
dgi("keys2").focus();
}
// Called onfocus from winbar
function focusKeys(){
inputBoxFocused=true;
updateWS();
}
/******************************************************************************
* Clipboard management
*****************************************************************************/
function sendClipboard(clipboardContent){
if(phpBrowser=='ie'){
if(typeof clipboardData != 'undefined') {
addEvent("mmv;"+XX+";"+YY+";");
addEvent("cp"+protect(clipboardData.getData("Text")));
sendEvents();
blink("clipboardOutBt",1);
}
else alert(captionClipboardNoData);
}
else{
if(!clipboardContent){
showSendClipboardBox();
}
else{
clipboardContent=dgi("clipboardText").value;
addEvent("mmv;"+XX+";"+YY+";");
addEvent("cp"+protect(clipboardContent));
sendEvents();
blink("clipboardOutBt",1);
closeClipboardBox();
}
}
}
function requestClipboard(){
addEvent("cg");
sendEvents();
blink("clipboardInBt",1);
}
function downloadClipboardFiles(){fas('','downloadClipboardFiles');}
function pasteInLocalClipboardIE(data){
dgi("clipboardText").innerText = unprotect(data);
var tr = dgi("clipboardText").createTextRange();
tr.execCommand("RemoveFormat");
tr.execCommand("Copy");
blink("clipboardInBt",3);
}
function resetClipboardBox(){dgi("clipboardText").value ="";}
function addToClipboardBox(data){dgi("clipboardText").value+=data;}
function pasteInLocalClipboard(data){
dgi("clipboardText").value=unprotect(data);
dgi("clipboardText").select();
showGetClipboardBox();
blink("clipboardInBt",3);
}
function closeClipboardBox(){
clipboardBoxFocused=false;
dgi("clipboardText").value='';
dd.elements["clipboardBox"].moveTo(-1000,50);
}
function showGetClipboardBox(){
dgi("clipboardSendBt").style.display='none';
dgi("clipboardCaptionRequest").style.display='inline';
dgi("clipboardCaptionSend").style.display='none';
dgi("clipboardCaptionPaste").style.display='none';
dgi("clipboardText").focus();
dd.elements["clipboardBox"].maximizeZ();
dd.elements["clipboardBox"].moveTo(20,50);
}
function showSendClipboardBox(){
dgi("clipboardSendBt").style.display='block';
dgi("clipboardCaptionRequest").style.display='none';
dgi("clipboardCaptionSend").style.display='inline';
dgi("clipboardCaptionPaste").style.display='inline';
dgi("clipboardText").focus();
dd.elements["clipboardBox"]
dd.elements["clipboardBox"].maximizeZ();
dd.elements["clipboardBox"].moveTo(Math.max(dd.elements["controlBox"].x,dd.elements["inputBox"].x),Math.max(dd.elements["controlBox"].y,dd.elements["inputBox"].y)+80);
}
/******************************************************************************
* Alternate click (iPhone)
*****************************************************************************/
function altClickShowMenu(){
if(altClickDragInProgress) {altClickAction('dragDrop'); return;}
altClickX=Math.round(mouseX*1.0/zoom);
altClickY=Math.round((mouseY-actualOffsetTop(dgi('squares')))*1.0/zoom);
var iw=24/iPhoneZoom();
dgi('target').style.width=(2*iw)+'px';
dgi('target').style.height=(2*iw)+'px';
dgi('target').style.left=(mouseX-iw)+'px'; dgi('target').style.top=(mouseY-iw)+'px';dgi('target').style.display='block';
if(altClickMenuShown) return;
setEvtInterval(0); // Stop sending events while alternate click menu is displayed
var bx=window.pageXOffset + window.innerWidth/2 - iw;
var by=window.pageYOffset + iw*4;
for(var i=0;i<dgn('acBt','all').length;i++){
dgn('acBt',i).className='acBt';
if(dgn('acBt',i).id!='acLc' && dgn('acBt',i).id!='acRc'){
dgn('acBt',i).style.padding=(iw/4)+'px';
dgn('acBt',i).firstChild.style.width=(2*iw)+'px'; dgn('acBt',i).firstChild.style.height=(2*iw)+'px';
}
else{
dgn('acBt',i).style.padding=(iw/2)+'px';
dgn('acBt',i).firstChild.style.width=(3*iw/2)+'px'; dgn('acBt',i).firstChild.style.height=(3*iw/2)+'px';
}
dgn('acBt',i).style.zIndex=1001;
switch(dgn('acBt',i).id){
case 'acLc':ofx=-1.5;ofy=-1.5;break;
case 'acDbl':ofx=0;ofy=-1.5;break;
case 'acRc':ofx=1.5;ofy=-1.5;break;
case 'acDrag':ofx=-1.5;ofy=0;break;
case 'acMove':ofx=0;ofy=0;break;
case 'acCancel':ofx=1.5;ofy=0;break;
default:ofx=0;ofy=1;break;
}
ofx*=2*iw;ofy*=2*iw;
dgn('acBt',i).style.left=(bx+ofx)+'px'; dgn('acBt',i).style.top=(by+ofy)+'px';
}
ofx=-3*iw;ofy=3*iw;
dgi('acText').style.width=(8*iw)+'px';
dgi('acText').style.height=(3*iw)+'px';
dgi('acText').style.padding=(iw/4)+'px';
dgi('acText').style.left=(bx+ofx)+'px'; dgi('acText').style.top=(by+ofy)+'px';
var snodes=dgi('acText').firstChild;
dgi('acText').style.zIndex=1001;
var fs=iw+'px';
dgi('acText').style.fontSize=iw;
dgi('acTxtInput').style.fontSize=iw*0.6;
dgi('acKeySelect').style.fontSize=iw*0.6;
while (snodes!=undefined && snodes!=null) {
if(snodes.style) snodes.style.fontSize='30px';
snodes=snodes.nextSibling;
}
altClickMenuShown=1;
}
function iPhoneZoom(){return Math.abs(window.orientation)==90?480/window.innerWidth:320/window.innerWidth;}
function updateOrientation(){}
function altClickHideMenu(){
for(var i=0;i<dgn('acBt','all').length;i++) dgn('acBt',i).style.left='-2000px';
dgi('acText').style.left='-2000px';
dgi('target').style.left='-2000px';
altClickMenuShown=0;
}
function altClickAction(action){
var mod=((dgi('acShift').checked)?'+':'')+((dgi('acAlt').checked)?'%':'')+((dgi('acCtrl').checked)?'^':'');
switch(action){
case 'dragPick':
altClickDragInProgress=1;altClickHideMenu();return;
break;
case 'dragDrop':
XX=Math.round(mouseX*1.0/zoom);
YY=Math.round((mouseY-actualOffsetTop(dgi('squares')))*1.0/zoom);
altClickDragInProgress=0;
addEvent('mld;'+altClickX+';'+altClickY+';'+mod); addEvent('mlu;'+XX+';'+YY+';'+mod);
break;
case 'dbl':
addEvent('mlc;'+altClickX+';'+altClickY+';'+mod); addEvent('mlc;'+altClickX+';'+altClickY+';'+mod);
break;
case 'lc':
addEvent('mlc;'+altClickX+';'+altClickY+';'+mod);
break;
case 'rc':
addEvent('mrc;'+altClickX+';'+altClickY+';'+mod);
break;
case 'mv':
addEvent('mmv;'+altClickX+';'+altClickY+';'+mod);
break;
}
sendEvents();
altClickHideMenu();
}
function altClickCheck(cb){
var cpt=dgi(cb).nextSibling;
cpt.style.color=(dgi(cb).checked)?'':'red';
dgi(cb).checked=(dgi(cb).checked)?false:'checked';
}
function altClickTxt(){
addEvent("k"+protect(dgi('acTxtInput').value));
dgi('acTxtInput').value='';
sendEvents();
altClickHideMenu();
}
function init(){
// Set inputBox and controlBox dimensions so content fit (WA)
inputBoxesResetSize();
// Init cache images
for(var i=0;i<squaresNb;i++){
imgBuff[i]=new Image();
imgBuff[i].alt=i;
imgBuff[i].onload=imgBuffLoaded;
}
// Set squares srcs
updateSquares();
// Disable context menu
D.oncontextmenu=function(){return false}
}